import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Random;

public class Test {

    public static void testInsert(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TestSort.insetSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-startTime));
    }
    public static void testshellSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TestSort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-startTime));
    }
    public static void testselectSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        //TestSort.selectSort(array);
        TestSort.selectSortPro(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时："+(endTime-startTime));
    }
    public static void testheapSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();

        TestSort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序排序耗时："+(endTime-startTime));
    }
    public static void testbubbleSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();

        TestSort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序排序耗时："+(endTime-startTime));
    }
    public static void testquickSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TestSort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序排序耗时："+(endTime-startTime));
    }
    public static void testmergeSort(int[] array) {//计算时间
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TestSort.mergeSort(array);
        //TestSort.mergeSortNor(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序排序耗时："+(endTime-startTime));
    }

    public static void testSimple(){
        int[] array = {6,4,20,15,7,8,55,6,14,88,2};
        System.out.println("排序前"+Arrays.toString(array));
        //TestSort.insetSortClass(array);
        //TestSort.shellSort(array);
        //TestSort.selectSort(array);
        //TestSort.selectSortPro(array);
        //TestSort.heapSort(array);
        //TestSort.bubbleSort(array);
        //TestSort.quickSort(array);
        //TestSort.mergeSort(array);
        TestSort.mergeSortNor(array);
        System.out.println("排序后"+Arrays.toString(array));
    }
    public static void testother(){
        int[] array = new int[10000];
        NorOrderArray(array);
        //orderArray(array);
        testInsert(array);
        testshellSort(array);
        testselectSort(array);
        testheapSort(array);
        testbubbleSort(array);
        testquickSort(array);
        testmergeSort(array);
    }
    public static void main(String[] args) {
        testSimple();
        //testother();

    }
    public static void orderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = i;//顺序
            //array[i] = array.length-1-i;//倒序
        }
    }
    public static void NorOrderArray(int[] array){//生成随机数
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_0000);
        }
    }
}
